package com.blockmeta.bbs.baselibrary.provider;

import android.app.Application;
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.Log;


import com.alibaba.android.arouter.facade.template.IProvider;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.Utils;

import skin.support.SkinCompatManager;
import skin.support.app.SkinCardViewInflater;
import skin.support.constraint.app.SkinConstraintViewInflater;
import skin.support.design.app.SkinMaterialViewInflater;

/**
 * @author AirThor
 * @date 2019/6/14.
 */
public class InitSdkProvider extends ContentProvider {
    private static Context mContext;
    public static final String IM_APPLICATIONCONTEXT_PROVIDER = "/immodule/IMApplicationContextProvider";

    @Override
    public boolean onCreate() {
        Log.i("author", "InitSdkProvider oncreate");
        mContext = getContext();

        initSkin();
        initUtils();
        return true;
    }


    public static <T extends IProvider> T getProvider(String routPath){
        return (T) ARouter.getInstance().build(routPath).navigation();
    }

    /**
     * 初始化常用工具类
     */
    private void initUtils() {
        Utils.init((Application) mContext);
    }



    private void initSkin() {
        // 基础控件换肤初始化
        SkinCompatManager.withoutActivity((Application) mContext)
                // material design 控件换肤初始化[可选]
                .addInflater(new SkinMaterialViewInflater())
                // CardView v7 控件换肤初始化[可选]
                .addInflater(new SkinCardViewInflater())
                // ConstraintView 控件换肤初始化[可选]
                .addInflater(new SkinConstraintViewInflater())
                // 关闭状态栏换肤，默认打开[可选]
                .setSkinStatusBarColorEnable(false)
                // 关闭windowBackground换肤，默认打开[可选]
                .setSkinWindowBackgroundEnable(true)
                // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤
                .setSkinAllActivityEnable(false)
                .loadSkin();
    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
        return null;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
        return 0;
    }
}
